#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    int strStr(string haystack, string needle) {
        if(needle.empty()){
            return 0;
        }
        int index = 0;
        if(func(haystack,needle,index)){
            return index;
        }
        return -1;

    }
    bool func(string& haystack,string& needle,int& index){
        if(index+needle.size() > haystack.size()){
            return false;
        }
        int status = 0;
        for(int i = 0;i<needle.size();++i){
            if(needle[i]!=haystack[i+index]){
                status = 1;
                break;
            }
        }
        if(status){
            return func(haystack,needle,++index);
        }
        return true;
    }
};

int main(){
    Solution S;
    cout<<S.strStr("aaaaa","aaab")<<endl;
    
}